package acm.蓝桥杯二分前缀;

import java.util.Scanner;

public class 差分矩阵 {
    static int[][] a;
    static int[][] b;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a = new int[sc.nextInt() + 2][sc.nextInt() + 2];
        b = new int[a.length][a[0].length];
        int q = sc.nextInt();
        for (int i = 1; i < a.length-1; i++) {
            for (int j = 1; j < a[i].length-1; j++) {
                a[i][j] = sc.nextInt();
                insert(i, j, i, j, a[i][j]);
            }
        }
        while (q-- > 0) {
            insert(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
        }
        int[][] sum = sum();
        for (int i = 1; i < sum.length-1; i++) {
            for (int j = 1; j < sum[0].length-1; j++) {
                System.out.print(sum[i][j] + " ");
            }
            System.out.println();
        }
    }

    public static int[][] sum() {
        for (int i = 1; i < a.length; i++) {
            for (int j = 1; j < a[0].length; j++) {
                a[i][j] = a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1] + b[i][j];
            }
        }
        return a;
    }

    public static void insert(int x1, int y1, int x2, int y2, int n) {
        b[x1][y1] += n;
        b[x1][y2+1] -= n;
        b[x2+1][y1] -= n; //+1?
        b[x2+1][y2+1] += n;
    }

}
